package com.songlanyun.modules.userbankcard.controller.admin;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.common.annotation.SysLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.songlanyun.modules.userbankcard.entity.BankCardIconEntity;
import com.songlanyun.modules.userbankcard.service.BankCardIconService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;


/**
 * 银行卡图标管理
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-12-14 14:56:29
 */
@RestController
@RequestMapping("admin/bankcard/icon")
public class BankCardIconAdminController {
    @Autowired
    private BankCardIconService bankCardIconService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("bankcardicon:bankcardicon:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = bankCardIconService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/select")
    //@RequiresPermissions("bankcardicon:bankcardicon:list")
    public R select(@RequestParam Map<String, Object> params) {
        List<BankCardIconEntity> bankCardIconEntityList = bankCardIconService.list(
                new LambdaQueryWrapper<BankCardIconEntity>()
                        .orderByAsc(BankCardIconEntity::getSort)
                        .orderByDesc(BankCardIconEntity::getCreateTime)

        );

        return R.ok().put("list", bankCardIconEntityList);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("bankcardicon:bankcardicon:info")
    public R info(@PathVariable("id") Long id) {
        BankCardIconEntity bankCardIcon = bankCardIconService.getById(id);

        return R.ok().put("data", bankCardIcon);
    }

    /**
     * 保存
     */
    @SysLog("保存银行卡图标")
    @RequestMapping("/save")
    //@RequiresPermissions("bankcardicon:bankcardicon:save")
    public R save(@RequestBody BankCardIconEntity bankCardIcon) {
        bankCardIconService.save(bankCardIcon);

        return R.ok();
    }

    /**
     * 修改
     */
    @SysLog("修改银行卡图标")
    @RequestMapping("/update")
    //@RequiresPermissions("bankcardicon:bankcardicon:update")
    public R update(@RequestBody BankCardIconEntity bankCardIcon) {
        bankCardIconService.updateById(bankCardIcon);

        return R.ok();
    }

    /**
     * 删除
     */
    @SysLog("删除银行卡图标")
    @RequestMapping("/delete/{id}")
    //@RequiresPermissions("bankcardicon:bankcardicon:delete")
    public R delete(@PathVariable("id") Long id) {
        bankCardIconService.removeById(id);

        return R.ok();
    }

}
